package hiring.tong.com.common;

import java.util.List;

public class PageMoedls<T> {
//查询的记录数
	private List<T> list;
//每页显示多少条数据;
	private int pageSize;
//当前页数；初始值为1
	private int pageNo;
//总共多少条记录数;
	private int pageTotal;
	
/**
 * 首页
 * 
 * */
	public int getFirst(){
		
		return 1;
	}
/**
 *上一页 
 */
	public int getPre(){
		if(pageNo<1){
		
			return 1;	
		}
		else{
      			return pageNo-1;
		}
		
	}
	/**
	 * 总共有多少页
	 * 
	 * */
	public int getAllpage(){
		return (int)Math.ceil((double)pageTotal/pageSize);
	}
	/**
	 * 下一页
	 * 
	 * */
	public int getNext(){
		if(pageNo>getAllpage()){
			return getAllpage();
		}
		else{
			return pageNo+1;
		}
		
	}
	
public PageMoedls(List<T> list, int pageSize, int pageNo, int pageTotal) {
		super();
		this.list = list;
		this.pageSize = pageSize;
		this.pageNo = pageNo;
		this.pageTotal = pageTotal;
	}
public List<T> getList() {
	return list;
}

public void setList(List<T> list) {
	this.list = list;
}

public int getPageSize() {
	return pageSize;
}

public void setPageSize(int pageSize) {
	this.pageSize = pageSize;
}

public int getPageNo() {
	return pageNo;
}

public void setPageNo(int pageNo) {
	this.pageNo = pageNo;
}

public int getPageTotal() {
	return pageTotal;
}

public void setPageTotal(int pageTotal) {
	this.pageTotal = pageTotal;
}
	
	
	
	
}
